Skip to content

Conversation

apocelipes
Copy link
Contributor

Each net interface has its flags. These flags show the interface and its IP's status/capabilities.

Flags have already been reported by 'ifconfig' and 'ip addr' commands:

ifconfig

Add the same capability to fastfetch:

Snipaste_2024-10-04_19-49-37
Snipaste_2024-10-04_20-42-56

I also added a new option '--localip-show-flags' to control whether getting interface flags (the default value is FALSE).

@apocelipes
Copy link
Contributor Author

Spellcheck's error is a noise.
image

This is just a flag name, we can do nothing about it.

{
.flag = IFF_UP,
.name = "UP",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer { IFF_UP, "UP" } so that they take less spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

{
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) == 0)
writeNIFlagsToStrBuf(&iface->flags, ifr.ifr_flags, nicFlags);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it ifa->ifa_flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getifaddrs will return all interfaces in the local system which we already got. It might be heavier than creating a socket then calling a ioctl.
And manpages say this function is not a part of the standard, it could be different on other systems.
So, I think using ioctl and ifreq here may be enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we have already called getifaddrs. Why not reuse its result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, getifaddrs already called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this advice, I'll change to reuse its result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@CarterLi
Copy link
Member

CarterLi commented Oct 4, 2024

This is just a flag name, we can do nothing about it.

You should add it to .codespellrc. You should also add this flag to json_schema.json

@apocelipes
Copy link
Contributor Author

This is just a flag name, we can do nothing about it.

You should add it to .codespellrc. You should also add this flag to json_schema.json

Done.

@CarterLi CarterLi merged commit 40ab735 into fastfetch-cli:dev Oct 5, 2024
16 checks passed
@apocelipes apocelipes deleted the feat/nic-flags branch October 5, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants